import React, { useEffect, useState } from "react";
import { Link, Outlet } from "react-router-dom";
import "./Homepage.less";
import http from "../../utils/http";
import {
  CloudTwoTone,
  DollarCircleTwoTone,
  // ContainerTwoTone,
} from "@ant-design/icons";
import store from "../../store/store";

export default function Homepage() {
  const [today, setToday] = useState("");
  const [money, setMoney] = useState("");
  const [todaydata, setTodaydata] = useState({});
  let usermsg = JSON.parse(sessionStorage.getItem("user")) || {};
  useEffect(() => {
    //获取今日数据
    http({
      url: "api/index/titleTime",
      method: "get",
      params: { aid: usermsg.id },
    }).then((res) => {
      if (res.code == 200) {
        setTodaydata(res.data);
        setToday(res.today);
        let mon = res.waitMoney.toFixed(2)
        setMoney(mon)
      }
    });
  }, []);
  return (
    <div>
      <div id="hp_Top">
        <div id="hp_headMsg">
          <p id="hp_headLeft">今天，</p>
          <span id="hp_headRight">
            <Link to="/home/ruku">
              <div className="hp_iconMsg">
                <span className="hp_icon">
                  <CloudTwoTone twoToneColor="#eb2f96" />
                </span>
                <span className="hp_msg">
                  <span>{todaydata.waiGetInRep}</span>
                  <p>待入库</p>
                </span>
              </div>
            </Link>
            {/* <Link to="/home/Aftersales">
            <div className="hp_iconMsg">
              <span className="hp_icon">
                <ContainerTwoTone twoToneColor="#eb2f96" />
              </span>
              <span className="hp_msg">
                <span>51</span>
                <p>待审核</p>
              </span>
            </div>
          </Link> */}
            <Link to="/home/financial">
              <div className="hp_iconMsg">
                <span className="hp_icon">
                  <DollarCircleTwoTone twoToneColor="#eb2f96" />
                </span>
                <span className="hp_msg">
                  <span>{money}</span>
                  <p>待提现</p>
                </span>
              </div>
            </Link>
          </span>
        </div>
        <p>
          {today}，欢迎您回到后台操作系统，累计售出{todaydata.totalSaleNum}
          件商品，继续加油~
        </p>
      </div>
      <Outlet />
    </div>
  );
}
